<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>后台管理系统模板</title>
    <link rel="icon" href="/static/admin/favicon.ico" type="image/ico">
    <link href="/static/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/admin/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/static/admin/css/style.min.css" rel="stylesheet">
    <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/admin/js/bootstrap.min.js"></script>
    <script src="/static/admin/js/bootstrap-notify.min.js"></script>
    <script type="text/javascript" src="/static/admin/js/lightyear.js"></script>
</head>

<body>
<div class="col-md-12">
    <div class="card">
        <div class="card-body">
                <div class="form-group">
                    <label for="oldPassword">旧密码</label>
                    <input class="form-control" type="password" id="oldPassword" name="oldPassword" placeholder="请输入旧密码..">
                </div>
                <div class="form-group">
                    <label for="new_password">新密码</label>
                    <input class="form-control" type="password" id="new_password" name="new_password" placeholder="请输入新密码..">
                </div>
                <div class="form-group">
                    <label for="newPassword">确认新密码</label>
                    <input class="form-control" type="password" id="newPassword" name="newPassword" placeholder="请输入确认密码..">
                </div>
                <div class="form-group">
                    <button class="btn btn-primary" id="btn" type="submit">修改</button>
                </div>
        </div>
    </div>
</div>
<script>

       $("#oldPassword").focus().blur(function () {
           $.post('/admin/shopAdmin/comparePass',{oldPass:$("#oldPassword").val()},function (res) {
               console.log(res);
               if (res.status === 200){
                   lightyear.notify(res.data,'success', 2000, 'mdi mdi-emoticon-happy', 'top', 'center');
               }else {
                   lightyear.notify(res.data,'danger', 2000, 'mdi mdi-emoticon-sad', 'top', 'center');
                   $("#oldPassword").focus();
               }
           })
       });

       $("#btn").click(function () {
           const newPass = $("#newPassword").val();
           const nPass = $("#new_password").val();
           if (newPass != null && newPass !== '' && newPass === nPass){
               $.post('/admin/shopAdmin/editPass',{newPass: newPass},function (res) {
                   console.log(res);
                   if (res.status === 200){
                       lightyear.notify(res.data,'success', 2000, 'mdi mdi-emoticon-happy', 'top', 'center');
                       window.location.href = "/sys/sysMenu/main";
                   }else {
                       lightyear.notify(res.data,'danger', 2000, 'mdi mdi-emoticon-sad', 'top', 'center');
                       $("#oldPassword").focus();
                   }
               })
           }else{
               lightyear.notify("两次密码不一致,请重新输入！",'danger', 2000, 'mdi mdi-emoticon-happy', 'top', 'center');
               $("#newPassword").focus();
           }
       })






</script>
</body>
</html>